package com.atcumt.shengce;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    
    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int n =  Integer.parseInt(reader.readLine());
        int[] nums = Arrays.stream(reader.readLine().split(" ")).mapToInt(Integer::valueOf).toArray();
        int res = solve(nums);
        System.out.println(res);
        reader.close();
    }

    private static int solve(int[] arrs) {
        int n = arrs.length;
        int[] arrs1 = new int[n];
        int[] arrs2 = new int[n];
        for (int i = 0; i < n; i++) {
            arrs1[i] = arrs[i] + i;
            arrs2[i] = arrs[i] - i;
        }
        int max = arrs1[0];
        int res = -1;
        for (int i = 1; i < n; i++) {
            res = Math.max(res, arrs2[i] + max);
            max = Math.max(max, arrs1[i]);
        }
        return res;
    }
}
